// 配置路由相关信息
import VueRouter from "vue-router";
import Vue from "vue";
import Main from "../main.vue";
import manageRouters from "./manage";
import Login from "../pages/login.vue";
import Register from "../pages/register.vue";
import Welcome from "../pages/welcome.vue";

import Unknown from "../../components/pages/window/unknown";
// 1.通过Vue.use(插件)
Vue.use(VueRouter);
const routes = [
  {
    path: "/main",
    component: Main,
    children: [...manageRouters],
  },
  {
    path: "/login",
    component: Login,
  },
  {
    path: "/",
    redirect: "/welcome",
  },
  {
    path: "/welcome",
    component: Welcome,
  },
  {
    path: "/unknown",
    component: Unknown,
  },
  {
    path: "/register",
    component: Register,
  }
];

const org = VueRouter.prototype.push;

VueRouter.prototype.push = function push(loc) {
  return org.call(this, loc).catch((err) => err);
};

// 2.创建VueRouter对象
const router = new VueRouter({
  routes,
});

// 3.将router传入到vue实例中
export default router;
